//快捷键功能
define(["jquery","Utils","Validator"],function($,Utils,Validator){

    var init = function () {
        _shift_s();
        _esc();
    }

    var _shift_s = function(){
        $(document).bind('keydown', 'Shift+s', function (evt) {
            console.log('key ==> ' + evt.key);
            alert("快捷键：Shift+s");
        });
    };
    var _esc = function(){
        $(document).bind('keydown', 'esc', function (evt) {
            console.log('key ==> ' + evt.key);
            alert("快捷键：ESC");
        });
    };
    //打开新增界面
    var shift_n = function (callback) {
        hotKeysTemplate(callback,"Shift+n");
    };
    //打开编辑界面
    var shift_e = function(callback){
        hotKeysTemplate(callback,"Shift+e");
    };
    //删除一条数据
    var shift_d = function (callback) {
        hotKeysTemplate(callback,"Shift+d");
    };
    //查询数据
    var shift_s = function(callback){
       hotKeysTemplate(callback,"Shift+s");
    };
    //打印
    var shift_p = function (callback) {
        hotKeysTemplate(callback,"Shift+p");
    };
    //导出-PDF
    var shift_f = function(callback){
        hotKeysTemplate(callback,"Shift+f");
    };
    //导出-CSV
    var shift_v = function (callback) {
        hotKeysTemplate(callback,"Shift+v");
    };
    //导出-Excel
    var shift_l = function (callback) {
        hotKeysTemplate(callback,"Shift+l");
    };

    //动态调用,接收一个数组参数
    var executeFunction = function (callback,keyword) {
        var args = [];
        args.push({"callback":callback,"keyword":keyword})
        Utils._execDynamicMethod_(hotKeysTemplate2,args);
    }

    //快捷键模板
    var hotKeysTemplate2 = function (args) {
        var callback = args["callback"];
        var keyword = args["keyword"];
        $(document).bind('keydown', keyword, function (evt) {
            console.log('key ==> ' + evt.key);
            if(callback) callback();
        });
    };

    //快捷键模板
    var hotKeysTemplate = function (callback,keyword) {
        $(document).bind('keydown', keyword, function (evt) {
            console.log('key ==> ' + evt.key);
            if(callback) callback();
        });
    };


    return {
        init:init,
        shift_n:shift_n,
        hotKeysTemplate:hotKeysTemplate,
        executeFunction:executeFunction
    }
});